package com.ymatou.iapi.productquery.testcase.old20210113;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mongodb.BasicDBObject;
import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.grouponmgr.parameter.SaveGrouponReq;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymatou.iapi.godfreightmgr.parameter.CreateCollectionGoodsAddressBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productprice.parameter.ProductAllPriceBean;
import com.ymatou.iapi.productquery.parameter.ApplyActivityDto;
import com.ymatou.iapi.productquery.parameter.GetProductInfoByProductIdBean;
import com.ymatou.iapi.productquery.parameter.ProductDetail.ProductInDetailBean;
import com.ymatou.iapi.productquery.service.GetProductInfoByProductIdCall;
import com.ymatou.iapi.productquery.service.GetProductInfoByTradeIsolationCall;
import com.ymatou.iapi.sellerproduct.service.BatchDeleteProductsCall;
import com.ymatou.iapi.sellerproduct.service.ChangeNewProductInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.mongo.YmtMongoDriverFactroy;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.database.mongo.jproduct.ProductTimeStampWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.utils.*;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

public class Ts_GetProductInfoByProductId {
	private static GetProductInfoByProductIdCall getProductInfoByProductIdCall = new GetProductInfoByProductIdCall();
	private static GetProductInfoByTradeIsolationCall getProductInfoByTradeIsolationCall = new GetProductInfoByTradeIsolationCall();
	
	private static Integer sellerId = Integer.valueOf(EnvSetup.getData("productpriceSellerId"));
	private static String sellerName = EnvSetup.getData("productpriceSellerName");	
	
	private static ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();
	private static int globalSellerId = Integer.parseInt(EnvSetup.getData("globalSellerId"));
	
	//vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";
	//vip渠道->代理1
	private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
	private static String vipAgentUserName1 = "dgsq408897016";
	
	
	@BeforeClass
	public static void setUp() {  
		Logger.createResultFile("非交易隔离查询接口,获取商品单品详细信息");
		try {
			GodfreightmgrService.deleteBySellerId(rootUserId);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getProductInfoByProductIdCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_GetProductInfoByProductId_001() {
		Logger.start(true,"普通单规格商品，普通单规格直播商品 查询");
		try {
			//发布商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false); 

			//check GetProductInfoByTradeIsolation 
			checkByProductId(productId,0,0,0,true);    
			
			//加入直播
            Thread.sleep(5000);
			int liveId = LiveCallService.createLiveInProgress(sellerName, Integer.valueOf(sellerId)).getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);

			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,liveId,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,liveId,true);
			
			//================================================================================
			//结束直播
			LiveCallService.closeLive(liveId, Integer.valueOf(sellerId));
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);
			
			//================================================================================
			//加入未开始直播
			liveId = LiveCallService.createLiveBeginInFuture(sellerName, Integer.valueOf(sellerId)).getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);

			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);

			ProductQueryCallService.checkTimeStampRedis(productId);
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_GetProductInfoByProductId_001_1() {
		Logger.start(true,"普通单规格商品，普通单规格直播商品 查询");
		try {
			//发布商品
			JSONObject addProductBean = JsonBeanHelper.getJsonBean("com.ymatou.iapi.sellerproduct/AddNewSellerProduct/AddNewProductTpl_Tc2.json");
			JsonBeanHelper.updateJsonBean(addProductBean, MapUtil.hashMap("UserID", sellerId,"LoginID", sellerName));
			String productId = SellerProductCallService.addNewProduct(addProductBean).getJSONObject("Data").getString("ProductID");
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);
			
			//加入直播
			int liveId = LiveCallService.createLiveInProgress(sellerName, Integer.valueOf(sellerId)).getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,liveId,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,liveId,true);
			
			//================================================================================
			//结束直播
			LiveCallService.closeLive(liveId, Integer.valueOf(sellerId));
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);
			
			//================================================================================
			//加入开始直播
			liveId = LiveCallService.createLiveInProgress(sellerName, Integer.valueOf(sellerId)).getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,liveId,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,liveId,true);
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetProductInfoByProductId_002() {
		Logger.start(true, "普通多规格商品,普通多规格直播商品 查询");
		try {
			String productId = ProductQueryCallService.getNewProduct(sellerId, sellerName);
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);
			
			//================================================================================
			//加入直播
			int liveId = LiveCallService.createLiveInProgress(sellerName, Integer.valueOf(sellerId)).getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,liveId,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,liveId,true);
			
			//================================================================================
			//结束直播
			LiveCallService.closeLive(liveId, Integer.valueOf(sellerId));
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);
			
			//================================================================================
			//加入未开始直播
			liveId = LiveCallService.createLiveBeginInFuture(sellerName, Integer.valueOf(sellerId)).getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_003() {
		Logger.start(true, "普通活动商品查询");
		int activityId = 0;
		try{
			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());
			
			//check GetProductInfoByProductId
			checkByProductId(productId,inaid,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,inaid,0,0,true);
			
			//结束活动
			//activityProductsWapper.update(inaid, MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(-1))); 
			AdminCallService.closeProductInActivity(String.valueOf(inaid));
			
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);
			
			
		}catch(Exception e){
			Logger.fail(e);
		}finally{
			if (activityId>0){ActivityPoolService.removeActivityIdFromPool(activityId);}
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_004() {
		Logger.start(true, "交易隔离活动商品查询");
		int activityId = 0;
		try{
			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,inaid,0,0,true);
			
			//结束活动
			//activityProductsWapper.update(inaid, MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(-1))); 
			AdminCallService.closeProductInActivity(String.valueOf(inaid));
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,0,0,0,true);
			
			
			
		}catch(Exception e){
			Logger.fail(e);
		}finally{
			if (activityId>0){ActivityPoolService.removeActivityIdFromPool(activityId);}
		}
	}
	
	

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetProductInfoByProductId_005() {
		Logger.start(true, "活动直播商品查询");
		try{
			
			String productId = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation(sellerId).getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());

			//================================================================================
			//加入直播
			int liveId = LiveCallService.createLiveInProgress(sellerName, Integer.valueOf(sellerId)).getJSONObject("Data").getInt("ActivityId");
			SellerProductCallService.addProductInLive(sellerId, liveId, productId);
			
			
			//check GetProductInfoByProductId
			checkByProductId(productId,inaid,0,liveId,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,inaid,0,liveId,true);
			
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductInfoByProductId_006() {
		Logger.start(true,"普通多规格商品，增加规格");
		try {
			//发布商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			//check GetProductDetailListByProductIdListCall
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductDetailListByTradeIsolationCall
			checkByProductId(productId,0,0,0,true);
			
			
			String fileName = "changenewproductinfocalltpl_003.json";
			new ChangeNewProductInfoCall().callAndGetReturnData(fileName,MapUtil.hashMap("LoginID", sellerName, "UserID", sellerId,
																"Product->sProductId",productId,"ProductID",productId));

			
			YMTDateUtil.waitTime(5);
			
			//check GetProductDetailListByProductIdListCall
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductDetailListByTradeIsolationCall
			checkByProductId(productId,0,0,0,true);
			
			

		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductInfoByProductId_007() {
		Logger.start(true,"普通下一场会员活动商品查询 ");
		int activityId = 0;
		try {
			String productId = ProductPriceCallService.getProductIdWithAllPrice(sellerId);
			
			ProductPriceCallService.getProdPriceWithActivityInFuture(sellerId,productId,MapUtil.hashMap("ActivityTemplateId", 3));
			
			if (YmtMongoDriverFactroy.IsNewJavaMongoOpen){
				new ActivityProductsWapper().update(productId, MapUtil.hashMap("nbuyer",true,"isolation",false));
			}
			
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			
			activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());
			//================================================================================
			//check GetProductDetailListByProductIdListCall
			checkByProductId(productId,0,inaid,0,false);
			
			//check GetProductDetailListByTradeIsolationCall
			checkByProductId(productId,0,inaid,0,true);
			

			//结束活动
			//activityProductsWapper.update(inaid, MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(1))); 
			AdminCallService.closeProductInActivity(String.valueOf(inaid));
			
			//================================================================================
			//check GetProductDetailListByProductIdListCall
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductDetailListByTradeIsolationCall
			checkByProductId(productId,0,0,0,true);
			
		}catch(Exception e){
			Logger.fail(e);
		}finally{
			if (activityId>0){ActivityPoolService.removeActivityIdFromPool(activityId);}
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductInfoByProductId_008() {
		Logger.start(true,"交易隔离下一场活动商品查询");
		int activityId = 0;
		try {
			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			
			ProductPriceCallService.getProdPriceWithActivityInFuture(sellerId,productId,MapUtil.hashMap("ActivityTemplateId", 1));
			
			if (YmtMongoDriverFactroy.IsNewJavaMongoOpen){
				new ActivityProductsWapper().update(productId, MapUtil.hashMap("nbuyer",true,"isolation",true));
			}
			
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			
			
			//================================================================================
			//check GetProductDetailListByProductIdListCall
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductDetailListByTradeIsolationCall
			checkByProductId(productId,0,inaid,0,true);
		
			//结束活动
			//activityProductsWapper.update(inaid, MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(1))); 
			AdminCallService.closeProductInActivity(String.valueOf(inaid));
			
			//================================================================================
			//check GetProductDetailListByProductIdListCall
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductDetailListByTradeIsolationCall
			checkByProductId(productId,0,0,0,true);
			
		}catch(Exception e){
			Logger.fail(e);
		}finally{
			if (activityId>0){ActivityPoolService.removeActivityIdFromPool(activityId);}
		}
	}
	
	@Test 
	@Category({P1.class})
	@TestCase
	public void Tc_GetProductInfoByProductId_009() {
		Logger.start(true,"查询商品删除");
		try {
			JSONObject addProductBean = JsonBeanHelper.getJsonBean("com.ymatou.iapi.sellerproduct/AddNewSellerProduct/AddNewProductTpl_Tc2.json");
			JsonBeanHelper.updateJsonBean(addProductBean, MapUtil.hashMap("UserID", sellerId,"LoginID", sellerName));
			String productId = SellerProductCallService.addNewProduct(addProductBean).getJSONObject("Data").getString("ProductID");
			
			//删除商品
			new BatchDeleteProductsCall().callAndGetReturnData(MapUtil.hashMap("ProductIds", new JSONArray(Arrays.asList(productId)), "UserID", sellerId));
			
			JSONObject ret1 = getProductInfoByProductIdCall.search(Arrays.asList(productId));
			Logger.verifyEquals(false,ret1.isNull("Data"), "删除商品应查出");
			
			JSONObject ret2 = getProductInfoByTradeIsolationCall.search(Arrays.asList(productId));
			Logger.verifyEquals(false,ret2.isNull("Data"), "删除商品不应查出");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
		
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_010() {
		Logger.start(true, "普通活动商品查询,库存为0");
		int activityId = 0;
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
			List<String> catalogs = ymtCatalogsIWapper.selectCatalogsByProductId(productId).stream().map(ele->ele.getsCatalogId()).collect(Collectors.toList());
			Date beginTime = YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getBeforeOrNextSecond(-3600));
			Date endTime = YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getBeforeOrNextSecond(3600));
			ApplyActivityDto activityDto = ProductPriceCallService.ApplyHighActivity("10",productId,beginTime,endTime);
			activityId = activityDto.getActivityId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			
			//check GetProductInfoByProductId
			checkByProductId(productId,inaid,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,inaid,0,0,true);
			
			//活动库存为0  活动不显示 但IsCurActivitySellOut=true
			ProductPriceCallService priceCallService = new ProductPriceCallService();

			priceCallService.updateActivityStockTo0InMgo(Integer.parseInt(activityDto.getAids().get(0)));
			ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
			checkByProductId(productId,-1*inaid,0,0,false);
			
		}catch(Exception e){
			Logger.fail(e);
		}finally{
			if (activityId>0){ActivityPoolService.removeActivityIdFromPool(activityId);}
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_011() {
		Logger.start(true, "交易隔离活动商品查询,库存为0");
		int activityId = 0;
		try{
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation(sellerId);
			String productId =productAllPriceBean.getProductId();
			int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			activityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("aid").toString());
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,inaid,0,0,true);
			
			//活动库存为0  活动不显示 但IsCurActivitySellOut=true
			ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
			ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
			
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);
			
			//check GetProductInfoByTradeIsolation
			checkByProductId(productId,-1*inaid,0,0,true);
			
		}catch(Exception e){
			Logger.fail(e);
		}finally{
			if (activityId>0){ActivityPoolService.removeActivityIdFromPool(activityId);}
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_012() {
		Logger.start(true, "全球优选商品,礼包商品");
		int activityId = 0;
		try{
			int sellerId = 20336378;
			AddSellerProductRequest addProdReq = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();

			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,1);
			List<String> catalogIds = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(x->x.getsCatalogId()).collect(Collectors.toList());

			ProductManagerCallServiceV2.UpdateCatalogCommisions(sellerId,productId,catalogIds.get(0),addProdReq.getSellerName(),new BigDecimal(10));

			checkByProductId(productId,0,0,0,false);

		}catch(Exception e){
			Logger.fail(e);
		}finally{
			if (activityId>0){ActivityPoolService.removeActivityIdFromPool(activityId);}
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_013() {
		Logger.start(true, "全球优选商品,优选团商品");
		int activityId = 0;
		try{
			int sellerId = 20336378;
			AddSellerProductRequest addpro = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,2);
			List<String> catalogIds = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(x->x.getsCatalogId()).collect(Collectors.toList());

			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(sellerId,productId,catalogIds.get(0),addpro.getSellerName(),Arrays.asList(new BigDecimal(10),new BigDecimal(9),new BigDecimal(8)));
			Thread.sleep(4000);
			//check GetProductInfoByProductId
			checkByProductId(productId,0,0,0,false);

		}catch(Exception e){
			Logger.fail(e);
		}finally{
			if (activityId>0){ActivityPoolService.removeActivityIdFromPool(activityId);}
		}
	}
	
	//渠道商
	private static int rootUserId = AgentUsers.rootUserId;
	private static String rootUserName = "NickautoTest";
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_014() {
		Logger.start(true, "查询限时抢八折后价格");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,false);
			double price=123.6;
			addAgentProductBean.getCatalogList().forEach(a->{
				a.getAgentPriceList().forEach(b->{
					b.setAgentPrice(price);
				});
				a.setDirectPrice(price);
			});
		 	String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//创建限时抢购活动
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId,productId);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(rootUserId, productId, catalogList);
			initProductaddactivity.getProductList().forEach(a->{
				a.getCatalogList().forEach(b->{
					b.setDiscount(new BigDecimal("8"));
				});
			});
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			Thread.sleep(4000);
			GetProductInfoByProductIdBean b=new GetProductInfoByProductIdBean();
			b.setNextActivityExpire(7);
			b.setProductId(productId);
			getProductInfoByProductIdCall.setData(b);
			getProductInfoByProductIdCall.callService();
			JsonObject jsonObject = getProductInfoByProductIdCall.getJsonObject();
			JsonObject ProductActivity = jsonObject.get("Data").getAsJsonObject().get("Product").getAsJsonObject().get("ProductActivity").getAsJsonObject();		
			Logger.verifyEquals(ProductActivity.get("MaxActivityPrice").getAsDouble(),ProductActivity.get("MinActivityPrice").getAsDouble(), "验证活动最低价和最低价是否一致");
			Logger.verifyEquals(price*0.8,ProductActivity.get("MinActivityPrice").getAsDouble(), "验证是否为八折价格");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_015() {
		Logger.start(true, "查询限时抢八折后价格---日元没有小数点");
		try{
			//创建渠道商，创建日币商品
			rootUserId = GodmchManageCallService.CreateCountrySellerMch("JPN");
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,false);
			addAgentProductBean.setCurrency("JPY");
			double price=123;
			addAgentProductBean.getCatalogList().forEach(a->{
				//设置价格
				a.getAgentPriceList().forEach(b->{
					b.setAgentPrice(price);
				});
				a.setDirectPrice(price);
			});
		 	String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//创建限时抢购活动
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId,productId);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(rootUserId, productId, catalogList);
			initProductaddactivity.getProductList().forEach(a->{
				a.getCatalogList().forEach(b->{
					b.setDiscount(new BigDecimal("8"));
				});
			});
			AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			Thread.sleep(4000);
			//查询商品详情
			
			GetProductInfoByProductIdBean b=new GetProductInfoByProductIdBean();
			b.setNextActivityExpire(7);
			b.setProductId(productId);
			getProductInfoByProductIdCall.setData(b);
			getProductInfoByProductIdCall.callService();
			JsonObject jsonObject = getProductInfoByProductIdCall.getJsonObject();
			JsonObject ProductActivity = jsonObject.get("Data").getAsJsonObject().get("Product").getAsJsonObject().get("ProductActivity").getAsJsonObject();		
			Logger.verifyEquals(ProductActivity.get("MaxActivityPrice").getAsDouble(),ProductActivity.get("MinActivityPrice").getAsDouble(), "验证活动最低价和最低价是否一致");
			Logger.verifyEquals(Math.floor(price*0.8),ProductActivity.get("MinActivityPrice").getAsDouble(), "验证是否为八折价格");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_016() {
		Logger.start(true, "查询限时抢八折后价格---折后价格小数点后超过两位的，直接舍掉");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,false);
			double price=123.36;//123.36*0.8=98.688  舍后应该是98.68
			addAgentProductBean.getCatalogList().forEach(a->{
				a.getAgentPriceList().forEach(b->{
					b.setAgentPrice(price);
					
				});
				a.setDirectPrice(price);
			});
		 	String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//创建限时抢购活动
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId,productId);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(rootUserId, productId, catalogList);
			initProductaddactivity.getProductList().forEach(a->{
				a.getCatalogList().forEach(b->{
					b.setDiscount(new BigDecimal("8"));
				});
			});
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			Thread.sleep(4000);
			GetProductInfoByProductIdBean b=new GetProductInfoByProductIdBean();
			b.setNextActivityExpire(7);
			b.setProductId(productId);
			getProductInfoByProductIdCall.setData(b);
			getProductInfoByProductIdCall.callService();
			JsonObject jsonObject = getProductInfoByProductIdCall.getJsonObject();
			JsonObject ProductActivity = jsonObject.get("Data").getAsJsonObject().get("Product").getAsJsonObject().get("ProductActivity").getAsJsonObject();		
			Logger.verifyEquals(ProductActivity.get("MaxActivityPrice").getAsDouble(),ProductActivity.get("MinActivityPrice").getAsDouble(), "验证活动最低价和最低价是否一致");
			Logger.verifyEquals(98.68,ProductActivity.get("MinActivityPrice").getAsDouble(), "验证是否为八折价格");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_017() {
		Logger.start(true, "查询优选团价格，多佣金比例");
		try {
			AddSellerProductRequest addSellerProductRequest = ProductManagerCallServiceV2
					.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data")
					.getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(globalSellerId, productId, 2);
			// 设置佣金比例、获取规格id、根据规格id，商品id，修改商品佣金
			BigDecimal saleCommission = new BigDecimal("0.111");
			List<String> catalogIds = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream()
					.map(x -> x.getsCatalogId()).collect(Collectors.toList());
			ProductManagerCallServiceV2.UpdateCatalogCommisions(addSellerProductRequest.getSellerId(), productId,
					catalogIds.get(0), addSellerProductRequest.getSellerName(), saleCommission);
			ProductManagerCallServiceV2.UpdateCatalogCommisions(addSellerProductRequest.getSellerId(), productId,
					catalogIds.get(1), addSellerProductRequest.getSellerName(), saleCommission);
			
			Thread.sleep(4000);
			GetProductInfoByProductIdBean b=new GetProductInfoByProductIdBean();
			b.setProductId(productId);
			b.setNextActivityExpire(7);
			getProductInfoByProductIdCall.setData(b);
			getProductInfoByProductIdCall.callService();
			JsonArray asJsonArray = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product").getAsJsonArray("CatalogList");
			//判断各个佣金价格
			asJsonArray.forEach(j->{
				JsonObject cataLog = j.getAsJsonObject();
				float price = cataLog.get("Price").getAsFloat();
				JsonArray CommissionList = cataLog.getAsJsonArray("CommissionList");
				Logger.verifyEquals(String.format("%.2f",Math.floor(price*0.6*saleCommission.floatValue()*100)/100),String.format("%.2f",CommissionList.get(0).getAsDouble()), "验证V1佣金");
				Logger.verifyEquals(String.format("%.2f",Math.floor(price*0.7*saleCommission.floatValue()*100)/100),String.format("%.2f",CommissionList.get(1).getAsDouble()), "验证V2佣金");
				Logger.verifyEquals(String.format("%.2f",Math.floor(price*0.83*saleCommission.floatValue()*100)/100),String.format("%.2f",CommissionList.get(2).getAsDouble()), "验证V3佣金");
				Logger.verifyEquals(String.format("%.2f",Math.floor(price*0.96*saleCommission.floatValue()*100)/100),String.format("%.2f",CommissionList.get(3).getAsDouble()), "验证V4佣金");
			});
			
			
			}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_018() {
		Logger.start(true, "查询礼包商品，多佣金比例");
		try{
			AddSellerProductRequest addSellerProductRequest = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(globalSellerId,productId,1);
			List<BigDecimal> saleCommissions = Arrays.asList(new BigDecimal("0.0700"),new BigDecimal("0.0800"),new BigDecimal("0.0900"),new BigDecimal("0.1000"));
			List<String> catalogIds = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(x->x.getsCatalogId()).collect(Collectors.toList());
			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(globalSellerId,productId,catalogIds.get(0),addSellerProductRequest.getSellerName(), saleCommissions);
			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(globalSellerId,productId,catalogIds.get(1),addSellerProductRequest.getSellerName(), saleCommissions);

			Thread.sleep(4000);
			GetProductInfoByProductIdBean b=new GetProductInfoByProductIdBean();
			b.setProductId(productId);
			b.setNextActivityExpire(7);
			getProductInfoByProductIdCall.setData(b);
			getProductInfoByProductIdCall.callService();
			JsonArray asJsonArray = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product").getAsJsonArray("CatalogList");
			//判断各个佣金价格
			asJsonArray.forEach(j->{
				JsonObject cataLog = j.getAsJsonObject();
				float price = cataLog.get("Price").getAsFloat();
				JsonArray CommissionList = cataLog.getAsJsonArray("CommissionList");
				Logger.verifyEquals(String.format("%.2f",price*saleCommissions.get(0).floatValue()),String.format("%.2f",CommissionList.get(0).getAsDouble()), "验证V1佣金");
				Logger.verifyEquals(String.format("%.2f",price*saleCommissions.get(1).floatValue()),String.format("%.2f",CommissionList.get(1).getAsDouble()), "验证V2佣金");
				Logger.verifyEquals(String.format("%.2f",price*saleCommissions.get(2).floatValue()),String.format("%.2f",CommissionList.get(2).getAsDouble()), "验证V3佣金");
				Logger.verifyEquals(String.format("%.2f",price*saleCommissions.get(3).floatValue()),String.format("%.2f",CommissionList.get(3).getAsDouble()), "验证V4佣金");
			});
			
			
			}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_019() {
		Logger.start(true, "查询礼包商品，多佣金比例");
		try{
			AddSellerProductRequest addSellerProductRequest = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(product.get("MarketCurrencyExchangeRate").getAsString(),"","验证币种信息");
			}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_020() {
		Logger.start(true, "价格服务增加币种");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(3000);
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyNotNull(product.getAsJsonObject("CurrencyExchangeRate").get("OnshoreExchangeRate").getAsBigDecimal().doubleValue(),"商品标价货币和参考汇率--美元");
			Logger.verifyEquals(product.getAsJsonObject("MarketCurrencyExchangeRate").get("OnshoreExchangeRate").getAsBigDecimal().doubleValue(),1.0,"商品市场价货币和参考汇率-人民币");
			}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_021() {
		Logger.start(true, "价格服务增加市场价");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			addAgentProductBean.getCatalogList().get(0).setMarketAmount(123.1);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(3000);
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(123.1, product.getAsJsonArray("CatalogList").get(0).getAsJsonObject().get("MarketAmount").getAsDouble(),"验证市场价");
			}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_022() {
		Logger.start(true, "查询验证拼团价格与版本号");
		try{
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});
			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-2, "yyyy-MM-dd HH:mm:ss"));
			savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(2, "yyyy-MM-dd HH:mm:ss"));
			Integer tuanid = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);
			Thread.sleep(5000);
			getProductInfoByProductIdCall.search(Arrays.asList(pid));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(product.get("GrouponVersion").getAsInt()>0,true, "商品是参加拼团的商品");
			Logger.verifyEquals(product.getAsJsonArray("CatalogList").get(0).getAsJsonObject().get("GrouponPrice").getAsDouble()>0,true, "商品参团价格》0");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_023() {
		Logger.start(true, "查询商品标签Tag");
		try{
			AddSellerProductRequest addSellerProductRequest = ProductManagerCallServiceV2.initAddSellerProductRequestV2(sellerId);
			addSellerProductRequest.getProduct().setProductTags(Arrays.asList("测试Tag1","测试Tag2"));
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(product.getAsJsonArray("Tag").get(0).getAsString(),"测试Tag1","验证商品标签1");
			Logger.verifyEquals(product.getAsJsonArray("Tag").get(1).getAsString(),"测试Tag2","验证商品标签2");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_024() {
		Logger.start(true, "查询商品商品库id");
		try{
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerSpuProduct(288484);
			String productId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(10000);
			
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(product.getAsJsonArray("Tag").get(0).getAsString(),"测试Tag1","验证商品标签1");
			Logger.verifyEquals(product.getAsJsonArray("Tag").get(1).getAsString(),"测试Tag2","验证商品标签2");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_025() {
		Logger.start(true, "查询待审核的商品，做删除处理/审核成功后，恢复正常");
		try{
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(3383);
			addProdReq.getProduct().setSecondCategoryId(1804);
			String productId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(product.get("Status").getAsInt(),-1,"验证商品标签1");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_026() {
		Logger.start(true, "查询审核失败的商品，做删除处理");
		try{
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(3383);
			addProdReq.getProduct().setSecondCategoryId(1804);
			String productId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			
			ProductManagerCallServiceV3.UpdateAuditStatus(productId, -1);
			Thread.sleep(3000);
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(product.get("Status").getAsInt(),-1,"验证商品标签1");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_027() {
		Logger.start(true, "查询奢品护航的商品");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(3383);
			addpro.getProduct().getCatalogList().get(0).setPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setNewPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setVipPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setMarketPrice(18000);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			
			Thread.sleep(3000);
			
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(true,product.get("IsLuxury").getAsBoolean(),"验证商品是否奢侈品");
			Logger.verifyEquals(true,product.getAsJsonArray("CatalogList").get(0).getAsJsonObject().get("IsLuxury").getAsBoolean(),"验证规格1奢侈品");
			Logger.verifyEquals(true,product.getAsJsonArray("CatalogList").get(1).getAsJsonObject().get("IsLuxury").getAsBoolean(),"验证规格2奢侈品");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetProductInfoByProductId_028() {
		Logger.start(true, "查询商品,验证商品副标题，销售区域，自提点Id，7天无理由退货");
		try{
			Integer sellerId = GodmchManageCallService.CreateGodMch();
			CreateCollectionGoodsAddressBean initCreateCollectionGoodsAddressBean = GodfreightmgrService.initCreateCollectionGoodsAddressBean(sellerId);
			int createcoll = GodfreightmgrService.createcollectiongoodsaddressCall(initCreateCollectionGoodsAddressBean);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId,
					sellerName, true);
			String subtitle="副标题"+TestDataManager.randomStr(10);
			addAgentProductBean.setSubTitle(subtitle);
			addAgentProductBean.setSaleArea(3);
			addAgentProductBean.setCollectionGoodsAddress(Arrays.asList(createcoll));
			addAgentProductBean.setNoReasonReturn(true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(3000);
			
			getProductInfoByProductIdCall.search(Arrays.asList(productId));
			JsonObject product = getProductInfoByProductIdCall.getJsonObject().getAsJsonObject("Data").getAsJsonObject("Product");
			Logger.verifyEquals(subtitle, product.get("SubTitle").getAsString(), "验证SubTitle");
			Logger.verifyEquals(3, product.get("SaleArea").getAsInt(), "验证SaleArea");
			Logger.verifyEquals(createcoll+"", product.getAsJsonArray("CollectionGoodsAddress").get(0).getAsInt(), "验证SubTitle");
			Logger.verifyEquals(true, product.get("NoReasonReturn").getAsBoolean(), "验证NoReasonReturn");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}

	 
	
	

	public void updateStock( String productid,int stock) throws Exception{
		ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();
		Map<String, Object> retInMgo = activityProductsWapper
				.getByProdId(productid);
		List<BasicDBObject> updateDBObjects = new ArrayList<>();
		JSONArray catalogsAry = new JSONArray(retInMgo.get("catalogs")
				.toString());
		for (int i = 0; i < catalogsAry.length(); i++) {
			activityProductsWapper.update(productid,
					MapUtil.hashMap("catalogs."+i+".stock", stock));
		}
		new ProductTimeStampWapper().update(productid, MapUtil.hashMap("aut", new Date()));
	}
	public static void checkByProductId(String prod,int prodInActivityId,int prodInNextActivityId,int liveId,boolean isTradeIsolation) throws Exception{
		YMTDateUtil.waitTime(2);
		List<String> prodList = Arrays.asList(prod);
		JSONObject ret;
		String chkdesc;
		if (isTradeIsolation){
			//交易隔离接口
			ret = getProductInfoByTradeIsolationCall.search(prodList);
			chkdesc = "检查 GetProductDetailListByTradeIsolation,  productId:"+prod;
		}else{
			//普通交易不隔离接口
			ret = getProductInfoByProductIdCall.search(prodList);
			chkdesc = "检查 GetProductDetailListByProductIdList, productId:"+prod;
		}
		ProductInDetailBean tgtProdInDetailBean = ProductQueryCallService.getProductInDetailBean(prod, prodInActivityId, prodInNextActivityId, liveId);
		Logger.debug("tgtProdInDetailBean:"+tgtProdInDetailBean);
		//返回码检查
		Logger.verifyEquals(200, ret.getInt("Code"), "返回码检查");
		//返回值取数据
		ProductInDetailBean actProdInDetailBean = ProductQueryCallService.getBeanFromJson(ret.getJSONObject("Data").getJSONObject("Product"),ProductInDetailBean.class);
		//比对
		ProductQueryCallService.compareProductInDetailBean(prodList,Arrays.asList(tgtProdInDetailBean), Arrays.asList(actProdInDetailBean),chkdesc);
	}

}
